var map = new BMap.Map("allmap");
map.enableScrollWheelZoom();
var point = new BMap.Point(116.404, 39.915);
map.centerAndZoom(point, 15);

var contextMenu = new BMap.ContextMenu();
var txtMenuItem = [ {
	text : 'add marker',
	callback : function(p) {
		addOneMark(map, p);
	}
} ];

for ( var i = 0; i < txtMenuItem.length; i++) {
	contextMenu.addItem(new BMap.MenuItem(txtMenuItem[i].text,
			txtMenuItem[i].callback, 100));
}

map.addContextMenu(contextMenu);

function addOneMark(map, p) {
	var marker = new MapMarker(p);
	marker.enableDragging();
	
	marker.addEventListener("rightclick", function() {
		var sContent = "lat:" + marker.getPosition().lat + " lng:"
				+ marker.getPosition().lng + " isClick:" + marker.isClick;

		var infoWindow = new BMap.InfoWindow(sContent);
		marker.openInfoWindow(infoWindow);
	});

	map.addOverlay(marker);
}



function MapMarker(point) {
	BMap.Marker.call(this, point);
	this.isClick = false;
}
MapMarker.prototype = new BMap.Marker();